package cn.gdut.chengcai.base;

import java.text.SimpleDateFormat;
import java.util.List;

import org.apache.commons.beanutils.BeanUtils;

import cn.gdut.chengcai.entity.FeedbackInfo;
import cn.gdut.chengcai.vo.FeedbackInfoVo;

public class FeedbackUtil {

	public static void fillVo(FeedbackInfo entity, FeedbackInfoVo vo) throws Exception {

		if (null != entity.getIsReply()) {
			BeanUtils.copyProperties(vo, entity);
			if (entity.getIsReply() == true) {
				vo.setIsReply("是");
			} else {
				vo.setIsReply("否");
			}
		} else {
			vo.setIsReply("否");
		}

		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		if (null != entity.getReplyTime()) {
			vo.setReplyTime(sdf.format(entity.getReplyTime()));
		} else {
			vo.setReplyTime("未处理");
		}
		if (null != entity.getCreateTime()) {
			vo.setCreateTime(sdf.format(entity.getCreateTime()));
		}

		if (null != entity.getUpdateTime()) {
			vo.setUpdateTime(sdf.format(entity.getUpdateTime()));
		}

	}

	public static void fillVoList(List<FeedbackInfo> list, List<FeedbackInfoVo> voList) throws Exception {
		if ((null != list) && (list.size() > 0)) {
			for (FeedbackInfo entity : list) {
				FeedbackInfoVo vo = new FeedbackInfoVo();
				fillVo(entity, vo);
				voList.add(vo);
			}
		}
	}

}
